package com.xh.echartsviewsystem.controller;

import com.xh.echartsviewsystem.entity.Result;
import com.xh.echartsviewsystem.service.PersonViewService;
import io.swagger.annotations.ApiOperation;
import lombok.var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author Admins
 */
@RestController
@RequestMapping("/views")
public class PersonViewController {

    @Autowired
    @Qualifier("personViewService")
    private PersonViewService personViewService;

    @ApiOperation(value = "查询出所有数据,JSON格式返回给前端")
    @PostMapping("/findAll")
    public Object findAll() {
        var persons = personViewService.findPerson();

        //断言 persons 不为 null 为null抛出异常
        assert persons != null;


        return new Result().successful("success",persons);
    }
}
